#ifndef __HERM_BASE_SECURITY_HEX_BIN_H__
#define __HERM_BASE_SECURITY_HEX_BIN_H__

#include <string>
#include "herm/export_symbols.h"

namespace herm{

class HERM_API HexBin 
{
public:
    HexBin();
    /***
    * Encode a byte array to hex string
    *
    * @param binaryData array of byte to encode
    * @return return encoded string
    */
    std::string Encode(const std::string& binaryData);
    /***
    * Decode hex string to a byte array
    *
    * @param encoded encoded string
    * @return return array of byte to encode
    */
/*    static public byte[] decode(String encoded) {
        if (encoded == null)
            return null;
        int lengthData = encoded.length();
        if (lengthData % 2 != 0)
            return null;

        char[] binaryData = encoded.toCharArray();
        int lengthDecode = lengthData / 2;
        byte[] decodedData = new byte[lengthDecode];
        byte temp1, temp2;
        char tempChar;
        for( int i = 0; i<lengthDecode; i++ ){
            tempChar = binaryData[i*2];
            temp1 = (tempChar < BASELENGTH) ? hexNumberTable[tempChar] : -1;
            if (temp1 == -1)
                return null;
            tempChar = binaryData[i*2+1];
            temp2 = (tempChar < BASELENGTH) ? hexNumberTable[tempChar] : -1;
            if (temp2 == -1)
                return null;
            decodedData[i] = (byte)((temp1 << 4) | temp2);
        }
        return decodedData;
    }*/
private:
    static const int  BASELENGTH   = 128;
    static const int  LOOKUPLENGTH = 16;
    unsigned char hexNumberTable[BASELENGTH];
    char lookUpHexAlphabet[LOOKUPLENGTH];
};
}

#endif 
